package com.ezops.util;

import java.util.Properties;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



public class SystemApplicationContext implements ApplicationContextAware {

	final Logger logger = LoggerFactory.getLogger(SystemApplicationContext.class);
	
	@Override
	public void setApplicationContext(ApplicationContext applicationContext)throws BeansException {
		
		logger.info("Called by Spring to set global context");
		ApplicationContextUtils.setContext(applicationContext);
		
		this.displaySystemProperties();
		

	}
	
	/**
	 * Display all of the systems properties into the logs
	 */
	public void displaySystemProperties(){
		
		logger.info("================================================================");
		Properties systemProperties = System.getProperties();
		logger.info("JAVA.VERSION="+          systemProperties.getProperty("java.version" ) );
		logger.info("JAVA.VENDOR ="+          systemProperties.getProperty("java.vendor" ) );
		logger.info("JAVA.VERSION.URL="+      systemProperties.getProperty("java.vendor.url" ) );
		logger.info("JAVA.VM.SPEC.VERSION="+  systemProperties.getProperty("java.vm.specification.version" ) );
		logger.info("JAVA.VM.SPEC.VENDOR="+   systemProperties.getProperty("java.vm.version" ) );
		logger.info("JAVA.VM.VENDOR="+        systemProperties.getProperty("java.vm.vendor" ) );
		logger.info("JAVA.SPEC.VERSION="+     systemProperties.getProperty("java.specification.version" ) );
		logger.info("JAVA.SPEC.VENDOR="+      systemProperties.getProperty("java.specification.vendor" ) );
		logger.info("JAVA.SPEC.NAME="+        systemProperties.getProperty("java.specification.name" ) );
		logger.info("JAVA.CLASS.VERSION="+    systemProperties.getProperty("java.class.version" ) );
		
		logger.info("JAVA.LIBRARY.PATH="+     systemProperties.getProperty("java.library.path" ) );
		logger.info("JAVA.IO.TMPDIR="+        systemProperties.getProperty("java.io.tmpdir" ) );
		logger.info("JAVA.COMPILER="+         systemProperties.getProperty("java.compiler" ) );
		logger.info("JAVA.EXT.DIRS"+          systemProperties.getProperty("java.ext.dirs" ) );
		logger.info("OS.NAME="+               systemProperties.getProperty("os.name" ) );
		logger.info("OS.ARCH="+               systemProperties.getProperty("os.arch" ) );
		logger.info("OS.VERSION="+            systemProperties.getProperty("os.version" ) );
		logger.info("FILE.SEPARATOR="+        systemProperties.getProperty("file.separator" ) );
		logger.info("PATH.SEPARATOR="+        systemProperties.getProperty("path.separator" ) );
		logger.info("LINE.SEPARATOR="+        systemProperties.getProperty("line.separator" ) );
		logger.info("USER.NAME="+             systemProperties.getProperty("user.name" ) );
		logger.info("USER.HOME="+             systemProperties.getProperty("user.home" ) );
		logger.info("USER.DIR="+              systemProperties.getProperty("user.dir" ) );
		logger.info("JAVA.CLASS.PATH="+       systemProperties.getProperty("java.class.path" ) );
		logger.info("================================================================");
	}
		

}
